<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>楼盘管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css?123456" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form">
	<input type="hidden" id="id" name="id" value="${hostItem.id}" />
	<input type="hidden" id="isGrounding" name="isGrounding" value="${hostItem.isGrounding}" />
	<input type="hidden" id="isRecommend" name="isRecommend" value="${hostItem.isRecommend}" />
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;楼盘名称</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="name" value="${hostItem.name}" placeholder="请输入标题" lay-verify="required" autocomplete="off" /></div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;项目经理</label>
		<div class="layui-input-block">
			<select class="form-control" name="manageMemberId" lay-verify="required" id="manageMemberId"></select>
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;城市</label>
		<div class="layui-input-block">
			<select class="form-control" lay-filter="cityId" name="cityId" lay-verify="required" id="cityId"></select>
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;区域</label>
		<div class="layui-input-block">
			<select class="form-control" name="areaId" lay-verify="required" id="areaId"></select>
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;封面图片</label>
		<div class="layui-input-block">
			<!--单图片开始-->
			<div class="layui-input-block cy-uploadpic-ctn" id="coverImage"  style=" float:left;margin:10px 0!important;position:relative; width: 90px; height: 90px;">
			</div>
			<!--单图片结束-->
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;轮播图</label>
		<div class="layui-input-block">
			<!--多图片开始-->
			<div class="layui-upload xyg-comp-muitImages" id="images">

			</div>
			<!--多图片结束-->
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;房屋特色</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="hostTag" value="${hostItem.hostTag}" placeholder="请输入房屋特色（多个用逗号隔开）" lay-verify="required" autocomplete="off" />
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;房屋类型</label>
		<div class="layui-input-block">
		<div id="hostType-select">
		</div>
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;参考单价</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="price" value="${hostItem.price}" placeholder="请输入参考单价(1200/m)" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;参考总价</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="allPrice" value="${hostItem.allPrice}" placeholder="请输入价格（120万元）" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;佣金描述</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="shareMoney" value="${hostItem.shareMoney}" placeholder="请输入佣金描述" lay-verify="required" autocomplete="off" />
		</div>
	</div>

	<!--<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;最小户型</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="minRooms" value="${hostItem.minRooms}" placeholder="请输入最小户型" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;最大户型</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="maxRooms" value="${hostItem.maxRooms}" placeholder="请输入最大户型" lay-verify="required" autocomplete="off" />
		</div>
	</div>-->

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;最小户型面积</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="minApartmentArea" value="${hostItem.minApartmentArea}" placeholder="请输入最小户型面积" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;最大户型面积</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="maxApartmentArea" value="${hostItem.maxApartmentArea}" placeholder="请输入最大户型面积" lay-verify="required" autocomplete="off" />
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;开盘时间</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" id="openTime" name="openTime" value="<#if hostItem.openTime??>${hostItem.openTime?string('yyyy-MM-dd')}</#if>" placeholder="请输入开盘时间" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;交房时间</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" id="deliveryTime" name="deliveryTime" value="<#if hostItem.deliveryTime??>${hostItem.deliveryTime?string('yyyy-MM-dd')}</#if>" placeholder="请选择交房时间" lay-verify="required" autocomplete="off" />
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;产权年限</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="propertyYear" value="${hostItem.propertyYear}" placeholder="请输入产权年限" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;水电类型</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="hydroelectric" value="${hostItem.hydroelectric}" placeholder="请输入水电类型" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;装修</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="decorate" value="${hostItem.decorate}" placeholder="请输入装修" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;户型</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="building" value="${hostItem.building}" placeholder="请输入楼栋" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;地址</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="address" value="${hostItem.address}" placeholder="请输入地址" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;经纬度</label>
		<div class="layui-input-block">
			<div class="layui-input-inline" style="width: 200px;">
				<input type="text" class="layui-input" name="longitude" value="${hostItem.longitude}" placeholder="请输入经度(180到-180)"  autocomplete="off" class="layui-input">
			</div>
			<div class="layui-form-mid">-</div>
			<div class="layui-input-inline" style="width: 200px;">
				<input type="text" class="layui-input" name="latitude" value="${hostItem.latitude}" placeholder="请输入纬度(90到-90)" autocomplete="off" class="layui-input">
			</div>
			<div class="layui-form-mid">
				<a href="https://lbs.amap.com/console/show/picker" target="_blank">查看经纬度</a>
			</div>
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<div class="layui-input-block">
			<button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submitBtn">确定</button>
			<button type="reset" class="layui-btn layui-btn-sm layui-btn-primary cancel">取消</button>
		</div>
	</div>
</form>

<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript" src="${s.base}/lib/KnifeZ/ace/ace.js"  charset="utf-8"></script>
<script type="text/javascript" src="${s.base}/lib/jquery/jquery-3.2.0.min.js"></script>

<script type="text/javascript">
	layui.use(['form', 'jquery', 'baseUtil', 'laydate', 'pageUtil','fileUtil','richTxtUtil','selectM','dialogUtil'],
    function() {
        var form = layui.form,
            $ = layui.jquery,
            richTxtUtil = layui.richTxtUtil,
            fileUtil = layui.fileUtil,
            baseUtil = layui.baseUtil,
            pageUtil = layui.pageUtil,
				dialogUtil = layui.dialogUtil,
            laydate = layui.laydate,
			selectM = layui.selectM;

        var hostType = '${hostItem.hostType}';
		var hostTypeList = [];
		if (hostType != null && hostType !="") {
			hostTypeList = hostType.split(",");
		}
        //单图片上传
        fileUtil.uploadImageNoSave('coverImage',"host/item","${hostItem.coverImage}");
		//多图片上传
        fileUtil.uploadMutiImageNoSave('images',"host/item","${hostItem.images}");

		//KnifeZ富文本
        // var index=richTxtUtil.layeditKnifezBuild("content",300);
        laydate.render({
            elem: '#deliveryTime',
            type: 'date',trigger: 'click'
        });
        laydate.render({
            elem: '#openTime',
            type: 'date',trigger: 'click'
        });

        // 房屋类型，可以多选
		var hostTypeSelect = null;
        pageUtil.initDict("host_item_type",
            function(dictData) {
                // pageUtil.showDict($("#hostType"), pageUtil.aceeptDictContentList(dictData, "host_item_type"), "", '${hostItem.hostType}');
				var hostTypeArr = [];
				if (dictData != null && dictData.length > 0) {
					for (var i = 0; i<dictData.length;i++){
						hostTypeArr.push({id:dictData[i].value,name:dictData[i].name})
					}
				}
				hostTypeSelect = selectM({
					//元素容器【必填】
					elem: '#hostType-select'
					//候选数据【必填】
					,selected: hostTypeList
					,data: hostTypeArr
				});
            });

        pageUtil.initDictByUrl("/hostCity/acceptSelect","host_city_type",
            function(dictData) {
                pageUtil.showDict($("#cityId"), pageUtil.aceeptDictContentList(dictData, "host_city_type"), "", '${hostItem.cityId}');
                // 初始化。
				var cityId = '${hostItem.cityId}';
				if (cityId == null || cityId == "") {
                    cityId = dictData[0].id;
                }
				if (dictData != null && dictData.length > 0) {
                    pageUtil.initDictByUrl("/hostArea/acceptSelect?cityId="+cityId,"host_area_type",
                        function(dictDataA) {
                            pageUtil.showDict($("#areaId"), pageUtil.aceeptDictContentList(dictDataA, "host_area_type"), "", '${hostItem.areaId}');
                        });
				} else {
                    pageUtil.showDict($("#areaId"), pageUtil.aceeptDictContentList([], "host_area_type"), "", '');
				}
            });

        pageUtil.initDictByUrl("/webMember/acceptGradeTwoSelect","web_member_grade_two",
            function(dictData) {
                pageUtil.showDict($("#manageMemberId"), pageUtil.aceeptDictContentList(dictData, "web_member_grade_two"), "", '${hostItem.manageMemberId}');
            });

        form.on('select(cityId)', function(data){
            pageUtil.initDictByUrl("/hostArea/acceptSelect?cityId="+data.value,"host_area_type",
                function(dictData) {
                    $("#areaId").empty();
                    pageUtil.showDict($("#areaId"), pageUtil.aceeptDictContentList(dictData, "host_area_type"), "", '');
                });
            form.render('select');
        });

        form.on('submit(submitBtn)',
            function(data) {
                // data.field.content = richTxtUtil.layeditBuildContent(index);
				var values = hostTypeSelect.values;
				if (values == null || values.length == 0) {
					dialogUtil.msg("请选择房屋类型");
					return false;
				}
				data.field.hostType=values.join(",");
                baseUtil.postMethodResult("/hostItem/addOrUpdate", data.field,
                    function(result) {
                        parent.location.reload();
                    });
                return false;
            });
    });
</script>
</body>

</html>